home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Garbo
/
Garbo.cdr
/
mac
/
hypercrd
/
xcmd
/
sprtxtrn.sea
/
Support Tools eXternals 1.2.5
/
card_40555.txt
< prev
next >
Wrap
Text File
|
1990-11-13
|
12KB
|
323 lines
-- card: 40555 from stack: in.5
-- bmap block id: 45194
-- flags: 0000
-- background id: 3858
-- name: SCSINameToID
----- HyperTalk script -----
on CloseCard
put empty into cd fld "id"
put empty into cd fld "volume"
pass CloseCard
end CloseCard
on HideObjects
hide cd fld "label"
hide cd fld "volume"
hide cd fld "id"
hide cd btn "try it!"
end HideObjects
on ShowObjects
show cd fld "label"
show cd fld "volume"
show cd fld "id"
show cd btn "try it!"
end ShowObjects
-- part 1 (field)
-- low flags: 01
-- high flags: 0002
-- rect: left=83 top=192 right=212 bottom=237
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: volume
-- part 3 (button)
-- low flags: 00
-- high flags: A002
-- rect: left=69 top=248 right=282 bottom=162
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 8192
-- line height: 16
-- part name: Try it!
----- HyperTalk script -----
on mouseUp
global errGlobal
put VolumePath() into driveName
if driveName = empty then exit mouseUp
put SCSINameToID(driveName, "noDialog:errGlobal") into driveID
if errGlobal Γëá empty then
answer "Error:" && errGlobal
put empty into errGlobal
put empty into cd fld "id"
put empty into cd fld "volume"
else
put driveID into cd fld "id"
put driveName into cd fld "volume"
end if
end mouseUp
-- part 4 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=22 top=170 right=186 bottom=258
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 10
-- style flags: 256
-- line height: 13
-- part name: label
-- part 6 (field)
-- low flags: 01
-- high flags: 0002
-- rect: left=21 top=192 right=212 bottom=82
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: id
-- part contents for background part 38
----- text -----
41/50
-- part contents for card part 4
----- text -----
SCSI ID SCSI Drive Name
-- part contents for background part 20
----- text -----
An XFCN which returns the SCSI ID of a SCSI drive with the specified name.
Calling syntax : SCSINameToID(diskName,<ΓÇ£noDialogΓÇ¥:errorGlobal>)
DRIVENAME: the name of the SCSI drive to check.
-- part contents for background part 42
----- text -----
{ SCSINameToID(diskName,ΓÇ£noDialog:ΓÇ¥errGlobal) }
{}
{ XFCN returns the ID of a SCSI disk with a given }
{ name. }
{}
{ brought to you by: Anup Murarka Eric Carlson }
{ ALINK: SKEPTIC ALINK: cyNic }
{ CIS: 76004,3356 }
{}
{ We are part of the Support Tools Development Group, }
{ Apple Computer, Inc. }
{}
{ please DO NOT contack Mac DTS for support of this code! }
{}
{ please DO contact the authors for support of this code! }
{}
{ Send comments, bug reports, requests to any of the above }
{ E-mail addresses or to:}
{}
{ (one of us) }
{ Apple Computer, Inc. }
{ 900 E. Hamilton, Ave. }
{ Campbell, CA 95008 }
{ M/S 72-L }
{}
{ Copyright: © 1989, 1990 by Apple Computer, Inc., all rights reserved. }
{}
{ written by Eric Carlson }
{ AppleLink: cyNic }
{ modification history }
{ Date Initials Comments }
{ ---- ------ ---------------------------------------------------- }
{ 1/5/90 ec first written }
{ 2/26/90 ec added new "askedForHelp" }
{ 4/25/90 ec fixed bug when passed name of a non SCSI disk }
{ 5/25/90 ec modified for A/UX compatibility. changed name from }
{ ΓÇ£SCSINumberΓÇ¥ to ΓÇ£SCSINameToIDΓÇ¥. changed version to }
{ 1.1}
{}
unit SCSINum;
interface
uses
HyperXCMD;
procedure MAIN (paramPtr: XCmdPtr);
implementation
procedure reportToUser (paramPtr: XCmdPtr;
msgStr: str255);
{}
{ report something back to the user. }
{ the last parameter (optional) to an external may contain }
{ "noDialog" or "noDialog:GlobalName". GlobalName is the name }
{ of a HyperTalk global variable into which error messages will be }
{ placed. we've decided to use this approach to avoid confusing }
{ an error message with a valid result being returned from an XFCN. }
{}
var
tempStr: str255;
begin
{check the last param to see if the user requested that}
{ we suppress the error dialog }
ZeroToPas(paramPtr, paramPtr^.params[paramPtr^.paramCount]^, tempStr);
UprString(tempStr, true);
if pos('NODIALOG', tempStr) = 0 then
{ no special error handling specified, throw up a dialog and return the error message }
begin
SendCardMessage(paramPtr, concat('answer "', msgStr, '"'));
paramPtr^.returnValue := PasToZero(paramPtr, msgStr);
end
else if (pos(':', tempStr) > 0) then
{ requested global AND noDialog so we fill in the global and return empty }
begin
tempStr := copy(tempStr, pos(':', tempStr) + 1, length(tempStr));
{ get the name of the HC global to fill }
SetGlobal(paramPtr, tempStr, PasToZero(paramPtr, msgStr));
{ and fill it }
paramPtr^.returnValue := PasToZero(paramPtr, ''); { return empty }
end
else
{ requested noDialog only so we return the error condition as the result }
paramPtr^.returnValue := PasToZero(paramPtr, msgStr);
end; { procedure }
function AskedForHelp (paramPtr: XCmdPtr;
syntaxMsg: Str255;
copyrightMsg: Str255): boolean;
{ check to see if the user sent a '?' or a '!' as }
{ the only parameter. if so we will respond with }
{ the calling syntax or the copyright/version info }
{ for this external }
{}
var
firstStr: str255;
begin
askedForHelp := false;
if paramPtr^.paramCount = 1 then
begin
ZeroToPas(paramPtr, paramPtr^.params[1]^, firstStr);
{ what is the first param? }
if firstStr = '?' then
begin
reportToUser(paramPtr, syntaxMsg);
askedForHelp := true
end { asked for help }
else if firstStr = '!' then
begin
reportToUser(paramPtr, copyRightMsg);
askedForHelp := true
end; { asked for copyright info }
end; { one parameter passed }
end; { function }
function LongToString (paramPtr: XCmdPtr;
num: LONGINT): Str255;
{ why, oh why did dan write this one as a procedure??? }
var
tempStr: str255;
begin
LongToStr(paramPtr, num, tempStr);
LongToString := tempStr;
end;
function BitTest (AddressToCheck: ptr;
TotalBits: integer;
BitToTest: longint): boolean;
{ function that allows caller to use std. 68000 bit notation instead of the Toolbox's reversed notation}
{ example: bit 0 (the least significant bit) in a byte is bit 7 in the Toolbox's notation}
begin
BitTest := BitTst(AddressToCheck, TotalBits - 1 - BitToTest);
end;
function AUXisRunning: boolean;
const
HWCfgFlag = $0B22;
begin
AUXisRunning := BitTest(pointer(HWCfgFlag), 16, 9);
end;
procedure SCSINameToID (paramPtr: XCmdPtr);
{ the BITNOT of a driver's ref num is it's number in the unit table. in the case of a driver for a SCSI disk the entry }
{ in the unit table is the drive's ID + 32 }
var
requestedVolName, volName: str255;
PB: HParamBlockRec;
volInfoErr: OSErr;
lastChar: char;
diskID: integer;
begin
if askedForHelp(paramPtr, 'SCSINameToID(diskName,<“noDialog”:errorGlobal>)', '© 1989 Apple Computer, Inc., v.1.1, by Eric Carlson, ') then
exit(SCSINameToID);
if paramPtr^.paramCount < 1 then { we need the disk name to search for }
begin
reportToUser(paramPtr, 'Disk name expected');
exit(SCSINameToID)
end;
ZeroToPas(paramPtr, paramPtr^.params[1]^, requestedVolName);
if not (AUXisRunning) then { it we're NOT running under A/UX (where names ARE case sensitive), }
begin
UprString(requestedVolName, true); { set the name to uppercase for comparison }
if pos(':', requestedVolName) <> 0 then { make sure the volume name doesn't have a colon }
requestedVolName := copy(requestedVolName, 1, pos(':', requestedVolName) - 1);
end
else if length(requestedVolName) > 1 then { we ARE under A/UX, and the disk name isn't one char long }
begin
lastChar := requestedVolName[length(requestedVolName)]; { grab the last char of the path }
if (lastChar = ':') or (lastchar = '/') then { name specified with directory sep char, drop it }
requestedVolName := copy(requestedVolName, 1, length(requestedVolName) - 1);
end;
zeroBytes(paramPtr, @PB, sizeOf(PB)); { start out with a clean paramblock }
PB.ioNamePtr := @volName;
PB.ioVolIndex := 0;
repeat
PB.ioVolIndex := PB.ioVolIndex + 1; { next volume }
volInfoErr := PBHGetVInfo(@PB, false); { get the next volume name }
if volInfoErr = noErr then
UprString(volName, true); { set the name to uppercase for comparison }
until (volInfoErr <> noErr) or (volName = requestedVolName);
if volInfoErr = noErr then { return the ID }
begin
diskID := BITNOT(PB.ioVDRefNum) - 32;
if (diskID >= 0) and (diskID < 7) then
paramPtr^.returnValue := PasToZero(paramPtr, LongToString(paramPtr, diskID))
else
paramPtr^.returnValue := PasToZero(paramPtr, concat(requestedVolName, ' is not a SCSI drive.'));
end
else
reportToUser(paramPtr, 'Volume not found.') { return the message }
end; { procedure volumeList}
procedure MAIN (paramPtr: XCmdPtr);
begin
SCSINameToID(paramPtr);
end;
end. { unit SCSINum}